{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Missing value imputation: CategoricalImputer\n",
    "\n",
    "\n",
    "CategoricalImputer performs imputation of categorical variables. It replaces missing values by an arbitrary label \"Missing\" (default) or any other label entered by the user. Alternatively, it imputes missing data with the most frequent category.\n",
    "\n",
    "**For this demonstration, we use the Ames House Prices dataset produced by Professor Dean De Cock:**\n",
    "\n",
    "Dean De Cock (2011) Ames, Iowa: Alternative to the Boston Housing\n",
    "Data as an End of Semester Regression Project, Journal of Statistics Education, Vol.19, No. 3\n",
    "\n",
    "http://jse.amstat.org/v19n3/decock.pdf\n",
    "\n",
    "https://www.tandfonline.com/doi/abs/10.1080/10691898.2011.11889627\n",
    "\n",
    "The version of the dataset used in this notebook can be obtained from [Kaggle](https://www.kaggle.com/c/house-prices-advanced-regression-techniques/data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "from  feature_engine.imputation import CategoricalImputer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Id</th>\n",
       "      <th>MSSubClass</th>\n",
       "      <th>MSZoning</th>\n",
       "      <th>LotFrontage</th>\n",
       "      <th>LotArea</th>\n",
       "      <th>Street</th>\n",
       "      <th>Alley</th>\n",
       "      <th>LotShape</th>\n",
       "      <th>LandContour</th>\n",
       "      <th>Utilities</th>\n",
       "      <th>...</th>\n",
       "      <th>PoolArea</th>\n",
       "      <th>PoolQC</th>\n",
       "      <th>Fence</th>\n",
       "      <th>MiscFeature</th>\n",
       "      <th>MiscVal</th>\n",
       "      <th>MoSold</th>\n",
       "      <th>YrSold</th>\n",
       "      <th>SaleType</th>\n",
       "      <th>SaleCondition</th>\n",
       "      <th>SalePrice</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>60</td>\n",
       "      <td>RL</td>\n",
       "      <td>65.0</td>\n",
       "      <td>8450</td>\n",
       "      <td>Pave</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Reg</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>2008</td>\n",
       "      <td>WD</td>\n",
       "      <td>Normal</td>\n",
       "      <td>208500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>20</td>\n",
       "      <td>RL</td>\n",
       "      <td>80.0</td>\n",
       "      <td>9600</td>\n",
       "      <td>Pave</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Reg</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>2007</td>\n",
       "      <td>WD</td>\n",
       "      <td>Normal</td>\n",
       "      <td>181500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>60</td>\n",
       "      <td>RL</td>\n",
       "      <td>68.0</td>\n",
       "      <td>11250</td>\n",
       "      <td>Pave</td>\n",
       "      <td>NaN</td>\n",
       "      <td>IR1</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "      <td>2008</td>\n",
       "      <td>WD</td>\n",
       "      <td>Normal</td>\n",
       "      <td>223500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>70</td>\n",
       "      <td>RL</td>\n",
       "      <td>60.0</td>\n",
       "      <td>9550</td>\n",
       "      <td>Pave</td>\n",
       "      <td>NaN</td>\n",
       "      <td>IR1</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>2006</td>\n",
       "      <td>WD</td>\n",
       "      <td>Abnorml</td>\n",
       "      <td>140000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>60</td>\n",
       "      <td>RL</td>\n",
       "      <td>84.0</td>\n",
       "      <td>14260</td>\n",
       "      <td>Pave</td>\n",
       "      <td>NaN</td>\n",
       "      <td>IR1</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>12</td>\n",
       "      <td>2008</td>\n",
       "      <td>WD</td>\n",
       "      <td>Normal</td>\n",
       "      <td>250000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 81 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   Id  MSSubClass MSZoning  LotFrontage  LotArea Street Alley LotShape  \\\n",
       "0   1          60       RL         65.0     8450   Pave   NaN      Reg   \n",
       "1   2          20       RL         80.0     9600   Pave   NaN      Reg   \n",
       "2   3          60       RL         68.0    11250   Pave   NaN      IR1   \n",
       "3   4          70       RL         60.0     9550   Pave   NaN      IR1   \n",
       "4   5          60       RL         84.0    14260   Pave   NaN      IR1   \n",
       "\n",
       "  LandContour Utilities  ... PoolArea PoolQC Fence MiscFeature MiscVal MoSold  \\\n",
       "0         Lvl    AllPub  ...        0    NaN   NaN         NaN       0      2   \n",
       "1         Lvl    AllPub  ...        0    NaN   NaN         NaN       0      5   \n",
       "2         Lvl    AllPub  ...        0    NaN   NaN         NaN       0      9   \n",
       "3         Lvl    AllPub  ...        0    NaN   NaN         NaN       0      2   \n",
       "4         Lvl    AllPub  ...        0    NaN   NaN         NaN       0     12   \n",
       "\n",
       "  YrSold  SaleType  SaleCondition  SalePrice  \n",
       "0   2008        WD         Normal     208500  \n",
       "1   2007        WD         Normal     181500  \n",
       "2   2008        WD         Normal     223500  \n",
       "3   2006        WD        Abnorml     140000  \n",
       "4   2008        WD         Normal     250000  \n",
       "\n",
       "[5 rows x 81 columns]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = pd.read_csv('houseprice.csv')\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "((1022, 79), (438, 79))"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# let's separate into training and testing set\n",
    "\n",
    "X_train, X_test, y_train, y_test = train_test_split(\n",
    "    data.drop(['Id', 'SalePrice'], axis=1), data['SalePrice'], test_size=0.3, random_state=0)\n",
    "\n",
    "X_train.shape, X_test.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Alley         0.939335\n",
       "MasVnrType    0.004892\n",
       "dtype: float64"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# these are categorical variables with missing data\n",
    "\n",
    "X_train[['Alley', 'MasVnrType']].isnull().mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAEWCAYAAACdaNcBAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAAAT60lEQVR4nO3de7BlZX3m8e8jLSHiBYS2h3RjGotWQ8xwscOQkHESO1JcjE0mhMFo6MGe6VQNSbCcSzBTGZOaqREzNWHQZEh1INpmvBE1oUeJgUKJmUqBNmC4iJY9DITu4dJyiyNRg/zmj/0ePTSn++xzzu6z2K/fT9Wu/a53vXvv39m1+um1373W2qkqJEl9ec7QBUiSJs9wl6QOGe6S1CHDXZI6ZLhLUocMd0nq0IqhCwA48sgja+3atUOXIUlT5eabb/5qVa2ca92zItzXrl3Ljh07hi5DkqZKknv3tc5pGUnqkOEuSR0y3CWpQ4a7JHXIcJekDhnuktQhw12SOmS4S1KHxjqJKclhwBXAq4AC3gJ8GfgIsBa4Bzi3qh5NEuAy4EzgCeCfV9Utky58Pmsv/uRyv+Si3HPJWUOXIKlD4+65XwZ8qqpeCRwP3AVcDFxfVeuA69sywBnAunbbAlw+0YolSfOaN9yTvAh4DXAlQFV9q6oeAzYC29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w282sdLwRWD1bY9HooyclV9bnZnUl+FNgzUE1LZrjv29fn6DsU2AwcARjuC/OyJNsZBdFM+zuq6g3DlDWVfgl4K/ADjObZZ3wN+N0hCppy/xa4Ksn7+O77uR44HzhvqKKWymmZMbSf1buIUbBfBfzXqnpo2KqmS5J/sr/1VfUXy1XLtGt7lLsY/cjJe5JsAn4OuAf4zap6ZH+P1zO1I2MuZPQjMgB3Ar87zf/ODff9aD+x9TbgTcA24LKqenTYqqZbklfv/YPDSV7vmZXjS3IL8NNV9UiS1wAfBn4FOAH4oao6Z8j6plVv26aHQu5Dkv8CfJ7RR90fqarfNNgn4g+SzOwdkeSNwG8MWM80OmjW3vk/A7ZW1ceq6jeAYwesa9p1tW26574PSZ5idArykzz9y8CpvlLc0JK8DPgo8AuMji0+H3h9Vfkj2WNKcgejM1OfTPIlYEtVfXZmXVW9av/PoLn0tm36heo+VJWfag6Aqro7yXmMLqH8N8BpVfV3w1Y1dT4E/EWSrwJ/x+h6RyQ5FpjKIHo26G3bdM9dyyLJ7Tz9E9BLGAXRNwG8HsrCJDkFOAq4tqq+3vpeDjy/qm4ZtLgp0+u2abhrWbQzffepqu5drlqk2XrdNg13LZt21cI7q+qVQ9cizdbjtum8spZN+ym9Lyd56dC1SLP1uG36haqW2+HAnUk+x6yzgD1DVc8CXW2bhruW29QeN6zudbVtOueuwSQ5Eni4hx8jVl962Dadc9eySHJKkhuSfDzJie1EnDuAB5OcPnR9+t7V67bpnruWRZIdwK8z+im4rcAZVXVjklcCH5q51ru03HrdNt1z13JZUVXXVtUfAw9U1Y0AVfWlgeuSutw2DXctl6dmtfc+pduPjxpSl9um0zJaFkm+zejwsgDfDzwxswo4pKqeO1Rt+t7W67ZpuEtSh5yWkaQOGe6S1CHDXZI6ZLhLUocMd0nq0P8HyFnhR7qgMDcAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# number of observations per category\n",
    "\n",
    "X_train['MasVnrType'].value_counts().plot.bar()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Imputation with string missing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "CategoricalImputer(variables=['Alley', 'MasVnrType'])"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "imputer = CategoricalImputer(\n",
    "    imputation_method='missing',\n",
    "    variables=['Alley', 'MasVnrType'])\n",
    "\n",
    "imputer.fit(X_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Missing'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# here we find the string that will be used for the imputation\n",
    "imputer.fill_value"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Alley': 'Missing', 'MasVnrType': 'Missing'}"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# same string for all variables\n",
    "\n",
    "imputer.imputer_dict_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "# perform imputation\n",
    "\n",
    "train_t = imputer.transform(X_train)\n",
    "test_t = imputer.transform(X_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAEWCAYAAACdaNcBAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnN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N7q2o4EDq+q6XotbZO4XU5L8dlX9aZK3M82pwz5mT6Pq5/ouYFRU1aenafufPmoZAe4XUyaf1rah1yrmwJ67gAfufLipqp7cdy0aHe4X+y577gKgqnYkuSXJEeN0Xx3tnvvFQJL1u5s/ihf6Ge4adhCwKcnVwDcmG0dxx9Wicr8Y3FjwDgYPjb+KqVtTjCyHZfSAfen5kFo87hcPDE89CziTwT3cPwi8p6o29VrYbhjumlaSJcCXx/2ByHow9wtIcgCDkP8z4A9G9Z5D43wRkzpJjk/ysSTvTXJsko3ARuCuJCf3XZ/64X7xYEkOSPJ84O8Z3G/nbcD7+q1q1+y5iyQbgNcxeJzcGuA5VfXpJE9m8NVz5B5EoIXnfjElySUMbp52OXBpVW3suaQZGe4iyfVVtaKbvrmqfmBo3kg+ZUYLz/1iSpL7mTqYPByaYfD8h8csflW759kyArh/aHrny8r96z++3C86VbXPDWHbcxdJdjDolQT4buCbk7OAR1TVSD5GTAvL/WLfZrhLUoP2ua8akqSZGe6S1CDDXZIaZLhLUoMMd0lq0P8DxkcI8WP0Mp4AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# we can observe in the below plot, the presence of a \n",
    "# new category, where before there were NA\n",
    "\n",
    "test_t['MasVnrType'].value_counts().plot.bar()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:>"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAEUCAYAAADQoHYKAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAAATzEl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6G+/j8HvAXwNaquj3JTwHfnnBNkg4SzrlLUoecc19kSd5XVf85yR/x3O1if8x7gktaCob74nugvW+ZaBWSDmpOy0hShzxyX2RJNu9vvY/Zk7QUDPfF97PANuAq4FZ8PJukCXBaZpElWQa8BTgf+NfAV4Crquq+iRYm6aDiee6LrKp2V9WfV9V64FRgK3Bzkotm2VSSFo3TMmPQnsB0NoOj99XAJ4AvTbImSQcXp2UWWZIrgdcB1wFXV9W9Ey5J0kHIcF9kSZ7luTvTDf/HPSjvTCdpMgx3SeqQX6hKUocMd0nqkOEuSR0y3CWpQ4a7JHXo/wPMnHgU9a2L1AAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "test_t['Alley'].value_counts().plot.bar()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Frequent Category Imputation\n",
    "\n",
    "We can also replace missing values with the most frequent category"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "CategoricalImputer(imputation_method='frequent',\n",
       "                   variables=['Alley', 'MasVnrType'])"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "imputer = CategoricalImputer(\n",
    "    imputation_method='frequent',\n",
    "    variables=['Alley', 'MasVnrType'])\n",
    "\n",
    "imputer.fit(X_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Alley': 'Pave', 'MasVnrType': 'None'}"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# in this attribute we find the most frequent category\n",
    "# per variable to impute\n",
    "\n",
    "imputer.imputer_dict_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "None       609\n",
       "BrkFace    301\n",
       "Stone       97\n",
       "BrkCmn      10\n",
       "Name: MasVnrType, dtype: int64"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_t = imputer.transform(X_train)\n",
    "test_t = imputer.transform(X_test)\n",
    "\n",
    "# let's count the number of observations per category\n",
    "# in the original train set\n",
    "\n",
    "X_train['MasVnrType'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "None       614\n",
       "BrkFace    301\n",
       "Stone       97\n",
       "BrkCmn      10\n",
       "Name: MasVnrType, dtype: int64"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# note that we have a few more observations in the \n",
    "# most frequent category, which for this variable\n",
    "# is 'None'\n",
    "\n",
    "train_t['MasVnrType'].value_counts()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "See how the number of observations for None in MasVnrType has increased from 609 to 614, thanks to replacing the NA with this label in the dataset."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Automatically select categorical variables\n",
    "\n",
    "When no variable list is passed when calling the imputer, all categorical variables will be selected by the imputer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'MSZoning': 'RL',\n",
       " 'Street': 'Pave',\n",
       " 'Alley': 'Pave',\n",
       " 'LotShape': 'Reg',\n",
       " 'LandContour': 'Lvl',\n",
       " 'Utilities': 'AllPub',\n",
       " 'LotConfig': 'Inside',\n",
       " 'LandSlope': 'Gtl',\n",
       " 'Neighborhood': 'NAmes',\n",
       " 'Condition1': 'Norm',\n",
       " 'Condition2': 'Norm',\n",
       " 'BldgType': '1Fam',\n",
       " 'HouseStyle': '1Story',\n",
       " 'RoofStyle': 'Gable',\n",
       " 'RoofMatl': 'CompShg',\n",
       " 'Exterior1st': 'VinylSd',\n",
       " 'Exterior2nd': 'VinylSd',\n",
       " 'MasVnrType': 'None',\n",
       " 'ExterQual': 'TA',\n",
       " 'ExterCond': 'TA',\n",
       " 'Foundation': 'PConc',\n",
       " 'BsmtQual': 'TA',\n",
       " 'BsmtCond': 'TA',\n",
       " 'BsmtExposure': 'No',\n",
       " 'BsmtFinType1': 'Unf',\n",
       " 'BsmtFinType2': 'Unf',\n",
       " 'Heating': 'GasA',\n",
       " 'HeatingQC': 'Ex',\n",
       " 'CentralAir': 'Y',\n",
       " 'Electrical': 'SBrkr',\n",
       " 'KitchenQual': 'TA',\n",
       " 'Functional': 'Typ',\n",
       " 'FireplaceQu': 'Gd',\n",
       " 'GarageType': 'Attchd',\n",
       " 'GarageFinish': 'Unf',\n",
       " 'GarageQual': 'TA',\n",
       " 'GarageCond': 'TA',\n",
       " 'PavedDrive': 'Y',\n",
       " 'PoolQC': 'Gd',\n",
       " 'Fence': 'MnPrv',\n",
       " 'MiscFeature': 'Shed',\n",
       " 'SaleType': 'WD',\n",
       " 'SaleCondition': 'Normal'}"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# create an instance to impute all categorical variables\n",
    "# with the most frequent category\n",
    "\n",
    "imputer = CategoricalImputer(imputation_method='frequent')\n",
    "\n",
    "# with fit, the transformer identifies the categorical variables\n",
    "# in the train set\n",
    "imputer.fit(X_train)\n",
    "\n",
    "# here we find a dictionary with the categorical variables\n",
    "# to imputation value: most frequent category\n",
    "imputer.imputer_dict_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "MSZoning         0.000000\n",
       "Street           0.000000\n",
       "Alley            0.939335\n",
       "LotShape         0.000000\n",
       "LandContour      0.000000\n",
       "Utilities        0.000000\n",
       "LotConfig        0.000000\n",
       "LandSlope        0.000000\n",
       "Neighborhood     0.000000\n",
       "Condition1       0.000000\n",
       "Condition2       0.000000\n",
       "BldgType         0.000000\n",
       "HouseStyle       0.000000\n",
       "RoofStyle        0.000000\n",
       "RoofMatl         0.000000\n",
       "Exterior1st      0.000000\n",
       "Exterior2nd      0.000000\n",
       "MasVnrType       0.004892\n",
       "ExterQual        0.000000\n",
       "ExterCond        0.000000\n",
       "Foundation       0.000000\n",
       "BsmtQual         0.023483\n",
       "BsmtCond         0.023483\n",
       "BsmtExposure     0.023483\n",
       "BsmtFinType1     0.023483\n",
       "BsmtFinType2     0.024462\n",
       "Heating          0.000000\n",
       "HeatingQC        0.000000\n",
       "CentralAir       0.000000\n",
       "Electrical       0.000978\n",
       "KitchenQual      0.000000\n",
       "Functional       0.000000\n",
       "FireplaceQu      0.467710\n",
       "GarageType       0.052838\n",
       "GarageFinish     0.052838\n",
       "GarageQual       0.052838\n",
       "GarageCond       0.052838\n",
       "PavedDrive       0.000000\n",
       "PoolQC           0.997065\n",
       "Fence            0.813112\n",
       "MiscFeature      0.956947\n",
       "SaleType         0.000000\n",
       "SaleCondition    0.000000\n",
       "dtype: float64"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# with transform we remove missing data\n",
    "\n",
    "train_t = imputer.transform(X_train)\n",
    "test_t = imputer.transform(X_test)\n",
    "\n",
    "# missing values in categorical variables in original train set\n",
    "X_train[imputer.variables_].isnull().mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "MSZoning         0.0\n",
       "Street           0.0\n",
       "Alley            0.0\n",
       "LotShape         0.0\n",
       "LandContour      0.0\n",
       "Utilities        0.0\n",
       "LotConfig        0.0\n",
       "LandSlope        0.0\n",
       "Neighborhood     0.0\n",
       "Condition1       0.0\n",
       "Condition2       0.0\n",
       "BldgType         0.0\n",
       "HouseStyle       0.0\n",
       "RoofStyle        0.0\n",
       "RoofMatl         0.0\n",
       "Exterior1st      0.0\n",
       "Exterior2nd      0.0\n",
       "MasVnrType       0.0\n",
       "ExterQual        0.0\n",
       "ExterCond        0.0\n",
       "Foundation       0.0\n",
       "BsmtQual         0.0\n",
       "BsmtCond         0.0\n",
       "BsmtExposure     0.0\n",
       "BsmtFinType1     0.0\n",
       "BsmtFinType2     0.0\n",
       "Heating          0.0\n",
       "HeatingQC        0.0\n",
       "CentralAir       0.0\n",
       "Electrical       0.0\n",
       "KitchenQual      0.0\n",
       "Functional       0.0\n",
       "FireplaceQu      0.0\n",
       "GarageType       0.0\n",
       "GarageFinish     0.0\n",
       "GarageQual       0.0\n",
       "GarageCond       0.0\n",
       "PavedDrive       0.0\n",
       "PoolQC           0.0\n",
       "Fence            0.0\n",
       "MiscFeature      0.0\n",
       "SaleType         0.0\n",
       "SaleCondition    0.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# no NA after the imputation in the categorical variables\n",
    "train_t[imputer.variables_].isnull().mean()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Impute with user defined string\n",
    "\n",
    "The user can also enter a specific string for imputation (instead of the default 'Missing'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "imputer = CategoricalImputer(variables='MasVnrType',fill_value=\"this_is_missing\")\n",
    "\n",
    "# we can fit and transform the train set\n",
    "train_t = imputer.fit_transform(X_train)\n",
    "\n",
    "# and then transform the test set\n",
    "test_t = imputer.transform(X_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'this_is_missing'"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# the string to be used for the imputation\n",
    "imputer.fill_value"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:>"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAE5CAYAAABrkmDiAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAAAWwklEQVR4nO3de7RkZX3m8e8jEBVpFKQlCGh7AQ3eADsEg0mMjIRbRDJqYAZlKZN2FCY4Oq5BM4lkTVRioi5NRiaNXNrEaHAkIwIqTEdDYqLYXAZokCWLS6DDpZUIjBcM8Js/ahdd3X36nNN9Lrt46/tZq9bZ9e5dp35da5+nd7373e9OVSFJassT+i5AkjT/DHdJapDhLkkNMtwlqUGGuyQ1aPu+CwDYbbfdatmyZX2XIUmPK1deeeX3qmrpVOvGItyXLVvGmjVr+i5Dkh5Xkty+pXV2y0hSgwx3SWqQ4S5JDTLcJalBhrskNchwl6QGGe6S1CDDXZIaZLhLUoPG4grV+bDstIv7LoHbzjiq7xIkCZjFkXuSvZN8LckNSdYmObVrPz3JuiTXdI8jR17z3iQ3J7kpya8t5D9AkrS52Ry5Pwy8u6quSrIEuDLJZd26j1XVH49unGQ/4DjgRcAzgf+TZN+qemQ+C5ckbdmMR+5VdVdVXdUtPwjcCOw5zUuOAT5XVQ9V1a3AzcBB81GsJGl2tuqEapJlwAHAt7qmU5Jcm+ScJLt0bXsCd4y87E6m+M8gyYoka5KsWb9+/dZXLknaolmHe5KdgC8A76yqB4AzgecB+wN3AR/ZmjeuqpVVtbyqli9dOuV0xJKkbTSrcE+yA4Ng/0xVXQBQVfdU1SNV9ShwFhu6XtYBe4+8fK+uTZK0SGYzWibA2cCNVfXRkfY9RjY7Fri+W74QOC7JE5M8B9gHuGL+SpYkzWQ2o2UOAd4EXJfkmq7tfcD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3CVper8C/A3w61OsG9t7qNotI0nzIMmJVbWq7zqGDHdJmgdJrqqqA/uuY8ihkJI0P5x+QJIaNFbdIIa7JM0Pj9wlqUHf6LuAUYa7JM1CklO7icOS5OwkVyU5bLi+qk7ps75NGe6SNDtv7SYOOwzYBXgTcEa/JW2Z4S5JszPsUz8S+POqWsuY9bOPMtwlaXauTHIpg3D/apIlwKM917RFXsQkSbOQ5AnA/sAtVfWDJE8H9qyqa/utbGrOLSNJ00jywqr6DoNgB3juJhOHjSWP3CVpGklWVtWKJF+bYnVV1asXvahZMNwlqUF2y0jSLCX5RWAZI9lZVZ/uraBpGO6SNAtJ/hx4HnAN8EjXXMBYhrvdMpI0C0luBParx0loOs5dkmbneuBn+y5ituyWkaRpJPkSg+6XJcANSa4AHhqur6rX9lXbdAx3SZreHzOYZuAPgdeNtA/bxpLhLknTqKq/BUiyw3B5KMmT+6lqZoa7JE0jyduBdzC4MnV0qoEljNkc7qMcLSNJ00jyVAZT/H4IOG1k1YNVdV8/Vc3McJekBjkUUpIaZLhLUoMMd0lqkOEuSQ36/5Ax8ktyTo8xAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# after the imputation we see the new category\n",
    "\n",
    "test_t['MasVnrType'].value_counts().plot.bar()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:>"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAEWCAYAAACdaNcBAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAAASNklEQVR4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YNDPPu0+4P19FDTh/gy4MMk5PLw9VwOvA47tq6hx2S0zC91j9U5mEOwXAu+sqnv6rWqyJPmtbc2vqi8sVS2TrjuivIPBQ07el+R44HeBW4G3VdW921pfW+pGxpzE4CEyAOuB90/y37nhvg3dI7b+BHg1cC7wnqr6Xr9VTbYkz938gcNJXuGVlbOX5BrgxVV1b5IXAhcAfwysAp5RVUf3Wd+kam3fdCjkViT5e+BrDL7qPruq3mawL4izkkwfHZHkOOCtPdYziXYYOjr/PWBtVV1UVW8FntpjXZOuqX3TI/etSPIQg0uQH+DnTwZO9J3i+pbkycC/Ab/PYGzx64BXVJUPyZ6lJDcyuDL1gSRfB9ZU1ZXT86rqWdv+DZpJa/umJ1S3oqr8VrMIquqbSY5lcAvlbwOHVdWP+61q4pwPfCHJd4AfM7jfEUmeCkxkEG0PWts3PXLXkkhyAz//DWh3BkF0P4D3Q5mbJAcBy4HLquqHXdu+wC5VdU2vxU2YVvdNw11LorvSd6uq6ralqkUa1uq+abhryXR3LVxfVU/vuxZpWIv7pv3KWjLdo/RuSfLEvmuRhrW4b3pCVUttN2B9kqsYugrYK1S1HWhq3zTctdQmdtywmtfUvmmfu3qTZBnw3RYeRqy2tLBv2ueuJZHkoCSfT3Jxkv27C3FuBO5Ocnjf9ekXV6v7pkfuWhJJ1gFvYfAouLXAy6rqK0meDpw/fa93aam1um965K6lsmNVXVZVHwPuqqqvAFTV13uuS2py3zTctVQeGpre/JJuvz6qT03um3bLaEkkeZDB8LIAvwz8aHoW8OiqemRftekXW6v7puEuSQ2yW0aSGmS4S1KDDHdJapDhLkkNMtwlqUH/D7d5V3Ls3jEhAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# which was not present in the original dataset\n",
    "\n",
    "X_test['MasVnrType'].value_counts().plot.bar()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "fenotebook",
   "language": "python",
   "name": "fenotebook"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.2"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
